package com.epk.pic.controller.base;

import com.epk.pic.service.PicService;
import com.epk.pic.vo.base.PageDomain;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

public class BaseController{

    protected Page<?> startPage(PageDomain base) {
        if (base.getPageNo() == null) {
            base.setPageNo(1);
        }
        if (base.getPageSize() == null) {
            base.setPageSize(PicService.getPageSize());
        }

        Page<?> objects;
        if (base.getOrderBy() != null && !base.getOrderBy().equals("")) {
            objects = PageHelper.startPage(base.getPageNo(), base.getPageSize(), base.getOrderBy() + " " + base.getAsc());
        } else {
            objects = PageHelper.startPage(base.getPageNo(), base.getPageSize());
        }

        return objects;
    }
}
